<?php
    include_once '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    $fecha1 = $_REQUEST['capass2'];
    $fecha2 = $_REQUEST['capass22'];
    
    $f1 = date('Y-m-d',strtotime($fecha1));
    $f2 = date('Y-m-d',strtotime($fecha2));
    
    $indi = "select case ate_diagEgreso when 11 then 'Legrados Obstetricos' when 12 then 'Legrados Ginecologicos' end as legrados, COUNT(*) as cantidad 
            from diagEGineco inner join atenMaterna on diagEGineco.dia_oid=ate_diagEgreso
            where ate_fecha between '".$f1."' and '".$f2."'
            group by ate_diagEgreso
            order by cantidad desc";
    $lsti = $con->query($indi);
    while($res = mssql_fetch_array($lsti)){
        $lst[] = $res;
    }
    $con->cerrarConexion();
    print_r(json_encode($lst));

?>